
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<title>单词趣味消消乐</title>
<style>
    :root {
        --main-bg: #FFF5F5;
        --container-bg: #FFFFFF;
        --accent: #FFB3C6;
        --text: #66462C;
    }

    body {
        background: var(--main-bg);
        margin: 0;
        min-height: 100vh;
        display: flex;
        justify-content: center;
        align-items: center;
        font-family: 微软雅黑, sans-serif;
    }

    .game-container {
        background: var(--container-bg);
        border-radius: 30px;
        padding: 30px;
        box-shadow: 0 8px 20px rgba(0,0,0,0.1);
        border: 3px solid var(--accent);
        width: 90%;
        max-width: 1200px;
    }

    .header {
        text-align: center;
        margin-bottom: 25px;
    }

    .title {
        font-size: 3.2em;
        color: var(--text);
        margin: 0 0 20px 0;
        text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
    }

    .controls {
        display: flex;
        gap: 20px;
        justify-content: center;
        margin-bottom: 25px;
    }

    .difficulty-btn {
        font-size: 1.2em;
        padding: 12px 30px;
        border-radius: 25px;
        background: var(--accent);
        color: white;
        border: none;
        cursor: pointer;
        transition: all 0.2s;
    }

    .difficulty-btn.active {
        background: #FF759F;
        transform: scale(1.05);
    }

    #timer {
        text-align: center;
        font-size: 2em;
        color: var(--text);
        margin: 15px 0;
    }

    #score {
        text-align: center;
        font-size: 1.5em;
        color: var(--text);
        margin: 15px 0;
    }

    .game-columns {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 30px;
        margin: 20px 0;
    }

    .column {
        background: #FFF0F0;
        border-radius: 20px;
        padding: 20px;
        min-height: 300px;
        display: flex;
        flex-wrap: wrap;
        gap: 15px;
        justify-content: center;
        align-content: flex-start;
    }

    .card {
        font-size: 1.8em;
        color: var(--text);
        background: white;
        border-radius: 20px;
        padding: 18px 35px;
        cursor: pointer;
        transition: all 0.2s;
        box-shadow: 0 3px 6px rgba(0,0,0,0.1);
        user-select: none;
        animation: cardAppear 0.3s ease-out;
    }

    @keyframes cardAppear {
        0% { transform: scale(0); }
        100% { transform: scale(1); }
    }

    .card.selected {
        transform: scale(0.95);
        background: #FFF5F5;
        box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    }

    .card.matched {
        animation: popOut 0.4s forwards;
    }

    @keyframes popOut {
        0% { transform: scale(1); opacity: 1 }
        100% { transform: scale(0); opacity: 0 }
    }

    .victory-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0,0,0,0.3);
        display: flex;
        justify-content: center;
        align-items: center;
        z-index: 1000;
    }

    .victory-card {
        background: white;
        padding: 40px 60px;
        border-radius: 20px;
        text-align: center;
        box-shadow: 0 10px 30px rgba(0,0,0,0.2);
        animation: scaleIn 0.3s ease-out;
    }

    @keyframes scaleIn {
        0% { transform: scale(0); }
        100% { transform: scale(1); }
    }
</style>
</head>
<body>
<div class="game-container">
    <div class="header">
        <h1 class="title">张冰瑶老师伴学营专属单词消消乐</h1>
        <div id="timer">时间: 0秒</div>
        <div id="score">成功: 0次 错误: 0次</div>
    </div>

    <div class="controls">
        <button class="difficulty-btn" data-difficulty="4">青铜</button>
        <button class="difficulty-btn" data-difficulty="6">钻石</button>
        <button class="difficulty-btn" data-difficulty="10">王者</button>
    </div>

    <div class="game-columns">
        <div class="column" id="english-column"></div>
        <div class="column" id="chinese-column"></div>
    </div>
</div>

<script>
// 词汇数据配置
const vocabulary = [
{word: "junior high", translation: "初级中学", type: " "},
{word: "ready", translation: "adj 准备好 (做某事) 的", type: " "},
{word: "textbook", translation: "n. 教科书，教材，课本", type: " "},
{word: "eraser", translation: "n. 橡皮", type: " "},
{word: "history", translation: "n. 历史", type: " "},
{word: "geography", translation: "n. 地理", type: " "},
{word: "biology", translation: "n. 生物", type: " "},
{word: "physics", translation: "n. 物理", type: " "},
{word: "information technology", translation: "信息技术", type: " "},
{word: "chemistry", translation: "n. 化学", type: " "},
{word: "jacket", translation: "n. 夹克，短上衣", type: " "},
{word: "red scarf", translation: "红领巾", type: " "},
{word: "hat", translation: "n. 帽子", type: " "},
{word: "grey", translation: "adj 灰色的", type: " "},
{word: "uniform", translation: "n. 制服", type: " "},
{word: "teaching building", translation: "教学楼", type: " "},
{word: "dining hall", translation: "食堂", type: " "},
{word: "lab", translation: "n. 实验室", type: " "},
{word: "hold", translation: "v. 召开，举行；进行", type: " "},
{word: "event", translation: "n. 活动", type: " "},
{word: "join", translation: "v. 参与，加入 (某项活动)", type: " "},
{word: "club", translation: "n. 俱乐部", type: " "},
{word: "introduce", translation: "v. 介绍", type: " "},
{word: "yourself", translation: "pron. 你自己；你们自己", type: " "},
{word: "everyone", translation: "pron. 每个人，人人", type: " "},
{word: "holiday", translation: "n. 假期，休假日", type: " "},
{word: "enjoy", translation: "v. 喜欢；享受・・的乐趣", type: " "},
{word: "nervous", translation: "adj 神经紧张的；焦虑不安的", type: " "},
{word: "classmate", translation: "n. 同班同学", type: " "},
{word: "hobby", translation: "n. 业余爱好，嗜好", type: " "},
{word: "need", translation: "v. 需要", type: " "},
{word: "activity", translation: "n. 活动", type: " "},
{word: "decoration", translation: "n. 装饰物", type: " "},
{word: "without", translation: "prep. 缺乏；没有", type: " "},
{word: "sentence", translation: "n. 句子", type: " "},
{word: "start", translation: "v. 开始 (做某事)", type: " "},
{word: "point out", translation: "指出，指明", type: " "},
{word: "mistake", translation: "n. 错误", type: " "},
{word: "polite", translation: "adj 有礼貌的，客气的", type: " "},
{word: "mind", translation: "n. 头脑；思想，思维", type: " "},
{word: "hers", translation: "pron. 她的", type: " "},
{word: "dry", translation: "adj 干的，干燥的", type: " "},
{word: "meaning", translation: "n. 意义；意思；含义", type: " "},
{word: "fact", translation: "n. 事实；真相", type: " "},
{word: "in fact", translation: "事实上", type: " "},
{word: "important", translation: "adj 重要的，重大的", type: " "},
{word: "remember", translation: "v. 记住，记得", type: " "},
{word: "really", translation: "adv 很，十分", type: " "},
{word: "problem", translation: "n. 问题，难题；困难", type: " "},
{word: "advice", translation: "n. 意见，建议；忠告，劝告", type: " "},
{word: "project", translation: "n. （学校的）课题，研究项目", type: " "},
{word: "task", translation: "n. 工作，任务", type: " "},
{word: "journey", translation: "n. 旅行，旅程；历程，过程", type: " "},
{word: "of course", translation: "当然，自然", type: " "},
{word: "together", translation: "adv 一起，共同，一齐，一块儿", type: " "},
{word: "pool", translation: "n. 水塘，水洼", type: " "},
{word: "sail", translation: "v. 起航", type: " "},
{word: "away", translation: "adv 朝另一方向", type: " "},
{word: "thought", translation: "n. 意见，主意，观点", type: " "},
{word: "life", translation: "n. 生活", type: " "},
{word: "primary school", translation: "小学", type: " "},
{word: "protect", translation: "v. 保护；防护", type: " "},
{word: "wind", translation: "n. 风", type: " "},
{word: "wide", translation: "adj 宽的，宽阔的", type: " "},
{word: "pain", translation: "n. （肉体上的）疼，痛，疼痛", type: " "},
{word: "gain", translation: "n. （尤指靠计划或努力得到的）好处，利益，改进", type: " "},
{word: "through", translation: "prep. 从一端至另一端，穿过，通过", type: " "},
{word: "storm", translation: "n. 暴风雨 (雪)", type: " "},
{word: "hope", translation: "v. 希望，期望，指望", type: " "},
{word: "rock music", translation: "摇滚乐", type: " "},
{word: "electric", translation: "adj 用电的；电动的", type: " "},
{word: "guitar", translation: "n. 吉他", type: " "},
{word: "band", translation: "n. 乐队，乐团", type: " "},
{word: "fun", translation: "n. 乐趣", type: " "},
{word: "sound", translation: "n. 声音", type: " "},
{word: "different", translation: "adj 不同的，不一样的", type: " "},
{word: "suddenly", translation: "adv 突然，突如其来地", type: " "},
{word: "hit", translation: "v. 使 (某人) 突然意识到", type: " "},
{word: "check", translation: "v. 检查，核查", type: " "},
{word: "rush", translation: "v. 冲，奔", type: " "},
{word: "festival", translation: "n. （电影、戏剧、音乐等的）节，节庆，汇演", type: " "},
{word: "practice", translation: "n. 练习", type: " "},
{word: "stage", translation: "n. 舞台", type: " "},
{word: "nod", translation: "v. 点头", type: " "},
{word: "instrument", translation: "n. 乐器", type: " "},
{word: "everybody", translation: "pron. 每个人，人人", type: " "},
{word: "skate", translation: "v. 滑冰，溜冰", type: " "},
{word: "volleyball", translation: "n. 排球 (运动)", type: " "},
{word: "photography", translation: "n. 摄影", type: " "},
{word: "tradition", translation: "n. 传统", type: " "},
{word: "paper - cutting", translation: "剪纸", type: " "},
{word: "social media", translation: "社交媒体，社会化媒体", type: " "},
{word: "knowledge", translation: "n. 知识；学问；认识", type: " "},
{word: "wild", translation: "adj 野生的", type: " "},
{word: "nature", translation: "n. 大自然，自然界", type: " "},
{word: "adventure", translation: "n. 历险，奇遇", type: " "},
{word: "awake", translation: "adj 醒着的", type: " "},
{word: "midnight", translation: "n. 午夜", type: " "},
{word: "appear", translation: "v. （尤指突然）出现，呈现", type: " "},
{word: "heart", translation: "n. 心 (脏)", type: " "},
{word: "almost", translation: "adv 几乎，差不多", type: " "},
{word: "tap", translation: "v. （用手指）轻拍，轻叩，轻敲", type: " "},
{word: "shake", translation: "v. 摇动", type: " "},
{word: "bit", translation: "adv 有点儿，稍微", type: " "},
{word: "lonely", translation: "adj 孤单的，寂寞的", type: " "},
{word: "magic", translation: "adj 有魔力的，神奇的", type: " "},
{word: "joy", translation: "n. 欢欣，愉快，喜悦", type: " "},
{word: "notebook", translation: "n. 笔记本", type: " "},
{word: "shelf", translation: "n. 隔板，架子", type: " "},
{word: "leave", translation: "v. 离开", type: " "},
{word: "page", translation: "n. （书、报纸、文件等的）页，面", type: " "},
{word: "ending", translation: "n. （故事、电影、活动等的）结局，结尾", type: " "},
{word: "silent", translation: "adj 不作声的", type: " "},
{word: "along", translation: "prep. 顺着；沿着", type: " "},
{word: "mountain", translation: "n. 高山，山岳", type: " "},
{word: "road", translation: "n. 路，道路，公路", type: " "},
{word: "handsome", translation: "adj （男子）英俊的，漂亮的", type: " "},
{word: "strict", translation: "adj 严格的，严厉的", type: " "},
{word: "follow", translation: "v. 跟着，跟随", type: " "},
{word: "postman", translation: "n. 邮递员；邮差", type: " "},
{word: "touching", translation: "adj 感人的；动人的", type: " "},
{word: "son", translation: "n. 儿子", type: " "},
{word: "serve", translation: "v. 为...... 工作；供职", type: " "},
{word: "area", translation: "n. （国家、市镇等的）地区，区域", type: " "},
{word: "absent", translation: "adj 不在的，缺席的", type: " "},
{word: "seldom", translation: "adv 很少，罕见，不常", type: " "},
{word: "position", translation: "n. 职位，职务", type: " "},
{word: "each", translation: "pron. （两个或两个以上物或人中的）每个，各", type: " "},
{word: "carry", translation: "v. 把 (某物或某人) 带至 (新的地点或位置)", type: " "},
{word: "across", translation: "prep. 横跨，跨越", type: " "},
{word: "memory", translation: "n. 记忆，回忆", type: " "},
{word: "tear", translation: "n. 眼泪；泪水", type: " "},
{word: "growth", translation: "n. （性格、智力或情感的）发展，成长", type: " "},
{word: "hide", translation: "v. 把...・・藏起来，隐藏", type: " "},
{word: "care", translation: "n. 担心；忧虑", type: " "},
{word: "hug", translation: "n. 拥抱", type: " "},
{word: "kiss", translation: "n. 吻", type: " "},
{word: "reason", translation: "n. 原因，理由", type: " "},
{word: "marry", translation: "v. 结婚；娶；嫁", type: " "},
{word: "harmony", translation: "n. 融洽相处", type: " "},
{word: "solve", translation: "v. 解决 (问题)", type: " "},
{word: "relationship", translation: "n. （人或团体之间的）关系", type: " "},
{word: "parent", translation: "n. 父，母", type: " "},
{word: "race", translation: "v./n. 比赛；赛车", type: " "},
{word: "finish", translation: "v. 完成，做完", type: " "},
{word: "serious", translation: "adj 严重的", type: " "},
{word: "disease", translation: "n. 疾病，病", type: " "},
{word: "trailer", translation: "n. 拖车，挂车", type: " "},
{word: "pull", translation: "v. 拉；扯；拖", type: " "},
{word: "refuse", translation: "v. 拒绝，回绝", type: " "},
{word: "result", translation: "n. 结果，后果", type: " "},
{word: "matter", translation: "v. （尤指对某人自己或对发生之事）重要，要紧，有关系", type: " "},
{word: "power", translation: "v. 给 (车辆或机器) 提供动力", type: " "},
{word: "unusual", translation: "adj 不平常的", type: " "},
{word: "treat", translation: "v. 请客，款待，招待", type: " "},
{word: "myself", translation: "pron. 我本人，我亲自，我自己", type: " "},
{word: "dumpling", translation: "n. 水饺", type: " "},
{word: "whole", translation: "adj 全部的，整个的", type: " "},
{word: "become", translation: "v. 成为，变成", type: " "},
{word: "chef", translation: "n. 厨师", type: " "},
{word: "cucumber", translation: "n. 黄瓜", type: " "},
{word: "hang", translation: "v. 悬挂", type: " "},
{word: "balloon", translation: "n. 气球", type: " "},
{word: "lantern", translation: "n. 提灯；灯笼", type: " "},
{word: "dish", translation: "n. （烹制好的）菜肴，一道菜", type: " "},
{word: "joke", translation: "v. 说笑话；开玩笑", type: " "},
{word: "shocked", translation: "adj 震惊的", type: " "},
{word: "laugh", translation: "v. 发出笑声，(大) 笑", type: " "},
{word: "pork", translation: "n. 猪肉", type: " "},
{word: "round", translation: "adj 圆形的，环形的", type: " "},
{word: "shape", translation: "n. 形，形状，外形", type: " "},
{word: "reunion", translation: "n. 团圆，团聚", type: " "},
{word: "piece", translation: "n. 片；块；段；截", type: " "},
{word: "knife", translation: "n. 刀", type: " "},
{word: "smell", translation: "n. 气味", type: " "},
{word: "laughter", translation: "n. 笑；笑声", type: " "},
{word: "fill", translation: "v. （使）充满；装满", type: " "},
{word: "meal", translation: "n. 一餐；饭", type: " "},
{word: "miss", translation: "v. 思念，想念，怀念 (某人)；错过", type: " "},
{word: "taste", translation: "n. 味道，滋味", type: " "},
{word: "celebrate", translation: "v. 庆祝", type: " "},
{word: "culture", translation: "n. 文化", type: " "},
{word: "usually", translation: "adv 通常地；惯常地", type: " "},
{word: "Christmas", translation: "n. 圣诞节 (期间)", type: " "},
{word: "waste", translation: "n. （金钱、技能等的）浪费", type: " "},
{word: "pollution", translation: "n. 污染", type: " "},
{word: "plastic", translation: "adj 塑料制的", type: " "},
{word: "duty", translation: "n （道德或法律上的）义务，责任", type: " "},
{word: "shine", translation: "v 发光，发亮", type: " "},
{word: "break", translation: "n 中断，暂停", type: " "},
{word: "emergency", translation: "n 紧急情况，不测事件", type: " "},
{word: "thirsty", translation: "adj 渴的，口渴的", type: " "},
{word: "challenge", translation: "n 挑战，具有挑战性的事物", type: " "},
{word: "patient", translation: "n 病人，患者", type: " "},
{word: "situation", translation: "n 形势，情况，状况，局面", type: " "},
{word: "regret", translation: "v 后悔 (做了某事)；对...... 感到遗憾", type: " "},
{word: "decision", translation: "n 决定，抉择", type: " "},
{word: "support", translation: "n 支持", type: " "},
{word: "medical", translation: "adj 医学的；医疗的", type: " "},
{word: "bright", translation: "adv 光明地；明亮地", type: " "},
{word: "festive", translation: "adj 欢乐的，欢庆的", type: " "},
{word: "firework", translation: "n 烟火，烟花", type: " "},
{word: "view", translation: "n 观点，意见", type: " "},
{word: "pigeon", translation: "n 鸽子", type: " "},
{word: "surprise", translation: "n 意想不到的事", type: " "},
{word: "knock around", translation: "（在某处）悠闲地度过", type: " "},
{word: "droppings", translation: "n （兽或鸟的）粪", type: " "},
{word: "boring", translation: "adj 无趣的，无聊的，乏味的", type: " "},
{word: "feed", translation: "v 喂养，饲养，给...... 食物", type: " "},
{word: "madly", translation: "adv 发狂地；无法控制地", type: " "},
{word: "scary", translation: "adj 可怕的，骇人的，恐怖的", type: " "},
{word: "research", translation: "n （对某一主题的）研究，探索", type: " "},
{word: "recognise", translation: "v 认出；认识；辨认出", type: " "},
{word: "themselves", translation: "pron 他们自己；她们自己；它们自己", type: " "},
{word: "mirror", translation: "n 镜子", type: " "},
{word: "itself", translation: "pron 自己，自身", type: " "},
{word: "maybe", translation: "adv 也许，大概，可能 (表示不肯定)", type: " "},
{word: "several", translation: "adj 几个，数个，一些", type: " "},
{word: "kilometre", translation: "n 千米，公里", type: " "},
{word: "get lost", translation: "迷路", type: " "},
{word: "speed", translation: "n 速度，速率", type: " "},
{word: "amazing", translation: "adj 惊人的；了不起的", type: " "},
{word: "enough", translation: "det 足够的，充足的，充分的", type: " "},
{word: "change", translation: "n 变化，改变", type: " "},
{word: "dolphin", translation: "n 海豚", type: " "},
{word: "beaver", translation: "n 河狸，海狸", type: " "},
{word: "no wonder", translation: "难怪", type: " "},
{word: "engineer", translation: "n 工程师；设计师", type: " "},
{word: "hero", translation: "n 英雄；偶像", type: " "},
{word: "rescue", translation: "n 营救，救援", type: " "},
{word: "missing", translation: "adj 找不到的", type: " "},
{word: "dead", translation: "adj 死的，去世的", type: " "},
{word: "dodo", translation: "n 渡渡鸟", type: " "},
{word: "as dead as a dodo", translation: "彻底死亡", type: " "},
{word: "museum", translation: "n 博物馆，博物院", type: " "},
{word: "island", translation: "n 岛，岛屿", type: " "},
{word: "ocean", translation: "n 海洋，大海", type: " "},
{word: "plenty", translation: "pron 丰富，充足，众多，大量", type: " "},
{word: "friendly", translation: "adj 友好的，友善的", type: " "},
{word: "peaceful", translation: "adj 和平的，非暴力的", type: " "},
{word: "arrive", translation: "v 到达，抵达", type: " "},
{word: "forest", translation: "n 森林，林区", type: " "},
{word: "hunt", translation: "v 打猎；猎杀", type: " "},
{word: "soon", translation: "adv 不久，即刻，很快", type: " "},
{word: "die out", translation: "消失；绝迹，灭绝", type: " "},
{word: "full", translation: "adj 满的；满是・・・・・・的", type: " "},
{word: "fantastic", translation: "adj 极好的，吸引人的，有趣的", type: " "},
{word: "as happy as a clam", translation: "非常高兴的，相当满足的", type: " "},
{word: "within", translation: "prep 在 (建筑或地区) 里", type: " "},
{word: "quarter", translation: "n 一刻钟，十五分钟", type: " "},
{word: "workshop", translation: "n 车间，工场", type: " "},
{word: "leaf", translation: "n 叶，叶子", type: " "},
{word: "collect", translation: "v 收集，采集；使集中", type: " "},
{word: "sunlight", translation: "n 阳光", type: " "},
{word: "root", translation: "n 根", type: " "},
{word: "send", translation: "v 送出，发出", type: " "},
{word: "rise", translation: "v 升高，上升", type: " "},
{word: "stem", translation: "n （植物的）茎，梗，柄", type: " "},
{word: "mix", translation: "v （使）混合，拌和", type: " "},
{word: "produce", translation: "v （自然地）生产，产生，出产", type: " "},
{word: "sugar", translation: "n 糖", type: " "},
{word: "product", translation: "n （自然过程或化学反应的）生成物", type: " "},
{word: "oxygen", translation: "n 氧", type: " "},
{word: "though", translation: "adv 可是，不过，然而", type: " "},
{word: "breathe", translation: "v 呼吸", type: " "},
{word: "dark", translation: "adj 昏暗的；黑暗的", type: " "},
{word: "rest", translation: "n 休息 (时间)", type: " "},
{word: "natural", translation: "adj 自然的，天然的", type: " "},
{word: "enter", translation: "v 进入", type: " "},
{word: "sunflower", translation: "n 向日葵", type: " "},
{word: "seed", translation: "n 种子，籽", type: " "},
{word: "grow", translation: "v 生长", type: " "},
{word: "rainforest", translation: "n （热带）雨林", type: " "},
{word: "influence", translation: "v 影响，对...... 起作用", type: " "},
{word: "climate", translation: "n 气候", type: " "},
{word: "corn silk", translation: "玉米须", type: " "},
{word: "rose", translation: "n 玫瑰；蔷薇", type: " "},
{word: "cotton", translation: "n 棉花", type: " "},
{word: "bamboo", translation: "n 竹，竹子", type: " "},
{word: "popular", translation: "adj 受大众喜爱的，受欢迎的", type: " "},
{word: "health", translation: "n 健康 (状况)", type: " "},
{word: "key", translation: "adj 至关重要的；必不可少的；关键的", type: " "},
{word: "teahouse", translation: "n 茶馆，茶楼，茶室", type: " "},
{word: "news", translation: "n 消息", type: " "},
{word: "coffee", translation: "n 咖啡", type: " "},
{word: "secret", translation: "n 秘密", type: " "},
{word: "husband", translation: "n 丈夫", type: " "},
{word: "adult", translation: "n 成人，成年人", type: " "},
{word: "weekend", translation: "n 周末", type: " "},
{word: "chat", translation: "v 闲聊，闲谈，聊天", type: " "},
{word: "relax", translation: "v 放松，休息", type: " "},
{word: "yard", translation: "n 庭院", type: " "},
{word: "biscuit", translation: "n 饼干", type: " "},
{word: "connect", translation: "v 联结，连接", type: " "}
];

// 游戏核心逻辑
let selectedCards = [];
let successCount = 0;
let errorCount = 0;
let totalPairs = 0;
let startTime = 0;
let timerInterval;

function initGame(pairCount) {
    // 重置游戏状态
    clearInterval(timerInterval);
    selectedCards = [];
    successCount = 0;
    errorCount = 0;
    totalPairs = pairCount;
    startTime = Date.now();
    
    // 随机选择指定数量的词汇对
    const selected = shuffle([...vocabulary]).slice(0, pairCount);
    const pairs = selected.flatMap(item => [
        {text: `${item.word} ${item.type}`, value: item.word, type: 'en'},
        {text: item.translation, value: item.word, type: 'cn'}
    ]);
    
    // 生成卡片
    const shuffledCards = shuffle(pairs);
    document.getElementById('english-column').innerHTML = 
        shuffledCards.filter(c => c.type === 'en').map(cardHTML).join('');
    document.getElementById('chinese-column').innerHTML = 
        shuffledCards.filter(c => c.type === 'cn').map(cardHTML).join('');
    
    // 更新界面
    updateScore();
    timerInterval = setInterval(updateTimer, 1000);
}

function cardHTML(card) {
    return `<div class="card" data-value="${card.value}" data-type="${card.type}">${card.text}</div>`;
}

function handleCardClick(card) {
    if (card.classList.contains('matched')) return;
    
    // 播放单词发音（使用有道发音服务）
    const word = card.dataset.value;
    const audio = new Audio(`https://dict.youdao.com/dictvoice?audio=${encodeURIComponent(word)}`);
    audio.play().catch(() => console.log('自动播放被阻止'));

    // 选择逻辑
    card.classList.add('selected');
    selectedCards.push(card);

    if (selectedCards.length === 2) {
        setTimeout(checkMatch, 500);
    }
}

function checkMatch() {
    const [first, second] = selectedCards;
    const isMatch = first.dataset.value === second.dataset.value;

    if (isMatch) {
        successCount++;
        selectedCards.forEach(c => c.classList.add('matched'));
        if (successCount === totalPairs) showVictory();
    } else {
        errorCount++;
        selectedCards.forEach(c => c.classList.remove('selected'));
    }

    selectedCards = [];
    updateScore();
}

function updateScore() {
    document.getElementById('score').textContent = 
        `成功: ${successCount}次 错误: ${errorCount}次`;
}

function updateTimer() {
    const seconds = Math.floor((Date.now() - startTime) / 1000);
    document.getElementById('timer').textContent = `时间: ${seconds}秒`;
}

function showVictory() {
    clearInterval(timerInterval);
    const overlay = document.createElement('div');
    overlay.className = 'victory-overlay';
    overlay.innerHTML = `
        <div class="victory-card">
            <h2>🎉 闯关成功！</h2>
            <p>用时：${Math.floor((Date.now() - startTime)/1000)}秒</p>
            <p>正确率：${Math.round(successCount/(successCount+errorCount)*100)}%</p>
            <button onclick="location.reload()">再来一次</button>
        </div>
    `;
    document.body.appendChild(overlay);
}

// 工具函数
function shuffle(array) {
    return array.sort(() => Math.random() - 0.5);
}

// 事件监听
document.querySelectorAll('.difficulty-btn').forEach(btn => {
    btn.addEventListener('click', () => {
        document.querySelectorAll('.difficulty-btn').forEach(b => b.classList.remove('active'));
        btn.classList.add('active');
        initGame(parseInt(btn.dataset.difficulty));
    });
});

document.querySelector('.game-columns').addEventListener('click', (e) => {
    if (e.target.classList.contains('card')) {
        handleCardClick(e.target);
    }
});

// 默认开始青铜难度
document.querySelector('[data-difficulty="4"]').click();
</script>
</body>
</html>